<template>
  <div>
    <div style="margin-top: 1rem">
        <el-button
            icon="el-icon-document-add"
            type="primary"
            @click="handleAdd"
            >添加</el-button
          >
    </div>

    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="Id" width="180">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.Id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="轮播图图片" width="180">
        <template slot-scope="">
          <span style="margin-left: 10px"></span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 对话框 -->
    <el-dialog title="轮播图信息" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="轮播图" :label-width="formLabelWidth">
          <!-- 上传 -->
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :file-list="fileList"
            list-type="picture"
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">
              只能上传jpg/png文件，且不超过500kb
            </div>
          </el-upload>
          
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 分页 -->
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pager.pageIndex"
        :page-size="pager.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pager.rowsTotal"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //上传
      fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
      dialogFormVisible: false,
      pager: {
        pageIndex: 1,
        pageSize: 10,
        rowsTotal: 30,
      },
      tableData: [
        {
          Id: "1",
          name: "1",
        },
        {
          Id: "2",
          name: "2",
        },
        {
          Id: "3",
          name: "3",
        },
      ],
      form: {
        id: 0,
        articleTypename: "",
      },
      formLabelWidth: "120px",
    };
  },
  methods: {
    //编辑
    handleEdit(index, row) {
      this.dialogFormVisible = true;
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    //添加
    handleAdd() {
      this.dialogFormVisible = true;
    },
    //确认
    confirm() {},
     //大小更改(分页)
    handleSizeChange(val) {
      console.log(val);
    },
    //当前更改(分页)
    handleCurrentChange(val) {
      console.log(val);
    },
    //上传
     handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      //上传
      handlePreview(file) {
        console.log(file);
      }
  },
};
</script>

<style>
</style>